﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLL;
using Model;
namespace TaoBaoProject.UserHandler
{
    /// <summary>
    /// Summary description for UpdateUserHandler
    /// </summary>
    public class UpdateUserHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Users user = new Users();
            user.Id = context.Request.Params["id"].ToString();
            user.UserName = context.Request.Params["UserName"].ToString();
            user.Password = context.Request.Params["Password"].ToString();
            user.IsAdmin = Convert.ToByte(context.Request.Params["IsAdmin"].ToString() == "true" ? "1" : "0");


            string qq = context.Request.Params["QQ"].ToString();
            string wangwang = context.Request.Params["Wangwang"].ToString();
            string zhifubaoaccount = context.Request.Params["ZhifubaoAccount"].ToString();
            string zhifubaoname = context.Request.Params["ZhifubaoName"].ToString();
            string rebatezhifubao = context.Request.Params["RebateZhifubao"].ToString();
            string rebatezhifubaoname = context.Request.Params["RebateZhifubaoName"].ToString();
            string caifutongaccount = context.Request.Params["CaifutongAccount"].ToString();
            string caifutongname = context.Request.Params["CaifutongName"].ToString();
            string shopid = context.Request.Params["ShopID"].ToString();
            string cash = context.Request.Params["Cash"].ToString();
            string cellphone = context.Request.Params["Cellphone"].ToString();
            string fixphone = context.Request.Params["Fixphone"].ToString();
            string receivename = context.Request.Params["ReceiveName"].ToString();
            string receiveaddress = context.Request.Params["ReceiveAddress"].ToString();
            string receivecellphone = context.Request.Params["ReceiveCellphone"].ToString();
            string receivefixphone = context.Request.Params["ReceiveFixphone"].ToString();
            string date = context.Request.Params["Date"].ToString();


            user.ContainFileds = "\"QQ\":\"" + qq + "\",\"Wangwang\":\"" + wangwang + "\"," +
                "\"ZhifubaoAccount\":\"" + zhifubaoaccount + "\",\"ZhifubaoName\":\"" + zhifubaoname + "\"," +
                "\"RebateZhifubao\":\"" + rebatezhifubao + "\",\"RebateZhifubaoName\":\"" + rebatezhifubaoname + "\"," +
                "\"CaifutongAccount\":\"" + caifutongaccount + "\",\"CaifutongName\":\"" + caifutongname + "\"," +
                "\"ShopID\":\"" + shopid + "\",\"Cash\":\"" + cash + "\",\"Cellphone\":\"" + cellphone + "\"," +
                "\"Fixphone\":\"" + fixphone + "\",\"ReceiveName\":\"" + receivename + "\"," +
                "\"ReceiveAddress\":\"" + receiveaddress + "\",\"ReceiveCellphone\":\"" + receivecellphone + "\"," +
                "\"ReceiveFixphone\":\"" + receivefixphone + "\",\"Date\":\"" + date + "\"";


            UserBLL.UpdateUser(user);
            string returnValue = "{id:'" + user.Id + "',UserName:'" + user.UserName + "',Password:'" + user.Password + "',IsAdmin:'" + user.IsAdmin + "',ContainsProFileds:'" + user.ContainFileds + "'}";
            context.Response.Write(returnValue);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}